#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>
#include <string.h>

void fun(char arr[], int n)
{
	int left = 0;
	int right = 0;

	int i = 0;

	while (arr[i] != '\0')
	{
		i++;
	}
	right = i;

	for (int j = 0; j < n; j++)
	{
		arr[right] = arr[left];
		left++;
		right++;
	}
	for (int i = left; i < right; i++)
	{
		printf("%c", arr[i]);
	}
	printf("\n");
}

int main()
{
	char arr[100] = { '0' };
	gets(arr);

	int num = 0;
	scanf("%d", &num);

	fun(arr, num);

	return 0;
}